﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for LogReviews
/// </summary>
public class LogReviews
{
    private Dictionary<int, int> reviews;

    public Dictionary<int, int> Reviews
    {
        get { return reviews; }
        set { reviews = value; }
    }
    private KeyValuePair<int, int>[] topReviews;

    public KeyValuePair<int, int>[] TopReviews
    {
        get {
            int i = 0;
            foreach (KeyValuePair<int, int> item in reviews.OrderBy(key => key.Value))
            {
                topReviews[i] = item;
                i++;
            }
            return topReviews; 
        }
        set { topReviews = value; }
    }

   
	public LogReviews()
	{
        reviews = new Dictionary<int, int>();
        topReviews = new KeyValuePair<int, int>[3];
	}

    internal void add(int key, int value)
    {
        if (reviews[key] != null)
            reviews[key] = value;
        else
            reviews.Add(key,value);
    }

    internal void sub(int key)
    {
        if (reviews[key] != null)
            reviews[key] = 1+reviews[key];
        else
            reviews.Add(key, 1);
    }
}